//package com.example.springboottest.student.jmx;
//
//import com.example.springboottest.student.model.Student;
//import org.springframework.data.rest.core.event.AbstractRepositoryEventListener;
//import org.springframework.jmx.export.annotation.ManagedOperation;
//import org.springframework.jmx.export.annotation.ManagedResource;
//import org.springframework.jmx.export.notification.NotificationPublisher;
//import org.springframework.jmx.export.notification.NotificationPublisherAware;
//import org.springframework.stereotype.Service;
//
//import javax.management.Notification;
//
///**
// * 一个监控Stu模块的MBean,每当操作stu表的时候，发送一个通知
// * 有两种方式监听这些事件：
// * 一种是实现AbstractRepositoryEventListener抽象类
// *
// * @Override public void onBeforeSave(Object entity) {
// * }
// * @Override public void onAfterDelete(Object entity) {
// * }
// * 另一种是使用注解
// * @HandleBeforeSave public void handlePersonSave(Person p) {
// * }
// * @HandleBeforeSave public void handleProfileSave(Profile p) {
// * }
// */
//@Service
//@ManagedResource
//public class StuMbean extends AbstractRepositoryEventListener<Student>
//        implements NotificationPublisherAware {
//    private NotificationPublisher np;
//
//    @Override
//    public void setNotificationPublisher(NotificationPublisher notificationPublisher) {
//        this.np = np;
//    }
//
//    @ManagedOperation
//    public void onAfterSave(Student student) {
//        System.out.println("student\t" + student.toString());
//        Notification notification = new Notification(
//                "taco.count", this,
//                1, "ID是\t" + student.getId() + "\t数据被修改");
//        np.sendNotification(notification);
//    }
//}
